CREATE TABLE [dbo].[tb_Criterios]
(
[idCriterio] [int] NOT NULL IDENTITY(1, 1),
[Mnemo] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Descripcion] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE TRIGGER [dbo].[updatetb_Criterios] ON [dbo].[tb_Criterios]
 FOR UPDATE AS 
 IF (update(idCriterio)) begin 
	 SELECT * FROM inserted 
	 IF @@ROWCOUNT = 1 begin 
		 UPDATE tb_FuncionesDeGrilla
		 SET Por = (SELECT idCriterio FROM inserted)
		 WHERE tb_FuncionesDeGrilla.Por = (SELECT idCriterio FROM deleted)
	end  ELSE begin 
		 ROLLBACK TRANSACTION 
 end 
 end
GO
ALTER TABLE [dbo].[tb_Criterios] ADD CONSTRAINT [PK_tb_Criterios] PRIMARY KEY NONCLUSTERED  ([idCriterio]) ON [PRIMARY]
GO
